package com.hyl.controller;

import com.hyl.entity.SysUser;
import com.hyl.service.SysUserService;
import com.hyl.util.PageUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.multipart.MultipartFile;

/**
 * UserController
 *
 * @author hyl
 * @date 2025-07-04
 */
@Controller
@RequestMapping("/main/user")
public class UserController extends BaseController {

    @Autowired
    private SysUserService userService;

    @RequestMapping("/page")
    public String userPage(@RequestParam(name = "pageNo",defaultValue = "1") Integer pageNo,
                           @RequestParam(name = "pageSize",defaultValue = "5") Integer pageSize,
                           Model model){
        PageUtil<SysUser> page = userService.selectPage(pageNo, pageSize);
        model.addAttribute("pageInfo", page);
        return "user/page";
    }

    @GetMapping("/save")
    public String tosave(){
        return "user/save";
    }

    @PostMapping("/save")
    public String save(SysUser user, MultipartFile idPic, MultipartFile workPic){

        return redirect("/main/user/page");
    }
}
